/-docs
/-editor
CodeMirrorEditor.ts
CompletionCodeMirrorEditor.ts
CssEditorType.ts
Editor.ts
EditorType.ts
HtmlEditorType.ts
JavaScriptEditorType.ts
TypeScriptEditorType.ts
x-last-PlainTextEditorType.ts
/-files
/-files-old
/-imports
/-layout
/-storage
/-tests ...
/-tests/files
/-tests/storage
TestCase.html
TestCase.ts
TestPage.css
TestPage.html
TestPage.ts
_sampleTests.ts
teapo-tests.html
teapo-tests.ts
/-typings
codemirror.d.ts
knockout.d.ts
typescriptServices.d.ts
websql.d.ts
zip.js.d.ts
TypeScriptService.ts
functions.ts
ko.ts
persistence.api.ts
persistence.ts
shell.ts
teapo.html
teapo.ts
xxxxxxxxxx
    static forEachTest(namespace: any, callback: (name: string, _this_: any, test: () => void) => void) {
1
module teapo.tests {
2
3
  export class TestPage {
4
5
    all: TestCase[] = [];
6
7
    notStarted = ko.observableArray<TestCase>([]);
8
    running = ko.observableArray<TestCase>([]);
9
    succeeded = ko.observableArray<TestCase>([]);
10
    failed = ko.observableArray<TestCase>([]);
11
12
    workQuantum = 50;
13
14
    private _continueStartingClosure = () => this._continueStarting();
15
    private _updateTimesInterval: number = null;
16
17
    constructor(
18
      namespace: any = teapo.tests,
19
      private _queueWorkItem: (action: () => void) => void = action => setTimeout(action, 10)) {
20
21
      this._loadTests(namespace);
22
23
    }
24
25
    start() {
26
      if (this._updateTimesInterval) {
27
        clearInterval(this._updateTimesInterval);
28
        this._updateTimesInterval = null;
29
      }
30
      
31
      if (this.all.length) {
32
        this._updateTimesInterval = setInterval(() => this._updateTimes(), 100);
33
      }
34
35
      this._continueStarting();
36
    }
37
38
    private _updateTimes() {
39
      if (this.running().length + this.notStarted().length === 0) {
40
        clearInterval(this._updateTimesInterval);
41
        this._updateTimesInterval = 0;
42
        return;
43
      }
44
45
      var now = dateNow();
46
      forEach(this.running(), t => t.updateTimes(now));
47
    }
48
49
    private _continueStarting() {
50
      var now = dateNow();
51
      forEach(this.running(), t => {
52
        t.updateTimes(now);
53
      });
54
      
55
      var nextRest = dateNow() + this.workQuantum;
56
      while (true) {
57
58
        if (!this.notStarted().length)
59
          return;
60
61
        this._startOne();
62
63
        if (!this.notStarted().length)
64
          return;
65
        
66
        if (dateNow() >= nextRest) {
67
          this._queueWorkItem(this._continueStartingClosure);
68
          return;
69
        }
70
      }
71
    }
72
73
    private _startOne() {
74
      var nextTest = this.notStarted.shift();
75
      this.running.push(nextTest);
76
65:19 function (): number